﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Core.Master" AutoEventWireup="true"
    CodeBehind="CreateCustomer.aspx.cs" Inherits="Pap.Web.Modules.Loan.Views.CreateCustomer"
    meta:resourcekey="PageResource1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script type="text/javascript">
        function renderType(value) {
            if (value)
                return '<asp:Literal runat="server" Text="<%$ Resources:Error %>" />';
            else
                return '<asp:Literal runat="server" Text="<%$ Resources:Warning %>" />';
        }
    </script>
    <ext:Store ID="storeCustomers" IDMode="Static" runat="server" AutoLoad="True" SerializationMode="Simple">
        <Reader>
            <ext:JsonReader ReaderID="ID">
                <Fields>
                    <ext:RecordField Name="ID" />
                    <ext:RecordField Name="Name" />
                    <ext:RecordField Name="SSN" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store ID="storeErrors" IDMode="Static" runat="server" AutoLoad="True" SerializationMode="Simple">
        <Reader>
            <ext:JsonReader ReaderID="ID">
                <Fields>
                    <ext:RecordField Name="IsError" />
                    <ext:RecordField Name="Message" Mapping="StatusString" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:FitLayout runat="server">
        <ext:Panel runat="server">
            <Body>
                <ext:RowLayout runat="server">
                    <ext:LayoutRow>
                        <ext:FormPanel ID="FormPanel1" runat="server" BodyStyle="padding:5px;" ButtonAlign="Right"
                            AutoScroll="true">
                            <Body>
                                <ext:FormLayout runat="server" ID="frmLayoutErrors" ElementStyle="" ItemCls="" LabelWidth="100">
                                    <ext:Anchor>
                                        <ext:TextField ID="txtSSID" runat="server" MaxLength="50" FieldLabel="<%$ Resources:LabelSSID %>"
                                            Text="" LabelStyle="text-align:left" EnableKeyEvents="true" Width="400" />
                                    </ext:Anchor>
                                    <ext:Anchor>
                                        <ext:MultiField runat="server" ID="fieldName" FieldLabel="<%$ Resources:LabelName %>">
                                            <Fields>
                                                <ext:TextField ID="txtName" runat="server" MaxLength="500" EnableKeyEvents="true"
                                                    Width="400" />
                                                <ext:Button ID="btnSearch" runat="server" Width="85" Text="<%$ Resources:SearchButton %>"
                                                    Icon="Magnifier">
                                                    <AjaxEvents>
                                                        <Click OnEvent="btnSearch_Click">
                                                            <EventMask ShowMask="true" Msg="Searching..." MinDelay="500" />
                                                        </Click>
                                                    </AjaxEvents>
                                                </ext:Button>
                                            </Fields>
                                        </ext:MultiField>
                                    </ext:Anchor>
                                </ext:FormLayout>
                            </Body>
                        </ext:FormPanel>
                    </ext:LayoutRow>
                    <ext:LayoutRow RowHeight="1">
                        <ext:Panel runat="server">
                            <Body>
                                <ext:RowLayout runat="server">
                                    <ext:LayoutRow RowHeight="0.5">
                                        <ext:GridPanel ID="gvCustomers" IDMode="Static" runat="server" StoreID="storeCustomers"
                                            Frame="True" StripeRows="True" TrackMouseOver="True" AutoScroll="true" SelectionSavingBuffer="10"
                                            Title="<%$ Resources:CustomersGridTitle %>" AutoExpandColumn="Name">
                                            <SelectionModel>
                                                <ext:CheckboxSelectionModel ID="CheckboxSelectionModel1" runat="server" SingleSelect="true"
                                                    AllowDeselect="false" />
                                            </SelectionModel>
                                            <ColumnModel>
                                                <Columns>
                                                    <ext:Column ColumnID="Name" Header="<%$ Resources:HeaderCustomerName %>" DataIndex="Name"
                                                        Sortable="True" />
                                                    <ext:Column Header="<%$ Resources:HeaderSSN %>" DataIndex="SSN" Sortable="true" />
                                                    <ext:CommandColumn Header="<%$ Resources:HeaderAvailability %>">
                                                        <Commands>
                                                            <ext:GridCommand CommandName="Availability" Text="<%$ Resources:Check %>" Icon="Calculator" />
                                                        </Commands>
                                                    </ext:CommandColumn>
                                                    <ext:CommandColumn Header="<%$ Resources:HeaderHistory %>">
                                                        <Commands>
                                                            <ext:GridCommand CommandName="History" Text="<%$ Resources:Show %>" Icon="Calendar" />
                                                        </Commands>
                                                    </ext:CommandColumn>
                                                </Columns>
                                            </ColumnModel>
                                            <AjaxEvents>
                                                <Command OnEvent="gvCustomers_Command">
                                                    <ExtraParams>
                                                        <ext:Parameter Name="CommandName" Value="command" Mode="Raw" Encode="False" />
                                                        <ext:Parameter Name="CustomerID" Value="record.data.ID" Mode="Raw" Encode="False" />
                                                        <ext:Parameter Name="CustomerName" Value="record.data.Name" Mode="Raw" Encode="False" />
                                                    </ExtraParams>
                                                </Command>
                                            </AjaxEvents>
                                        </ext:GridPanel>
                                    </ext:LayoutRow>
                                    <ext:LayoutRow RowHeight="0.5">
                                        <ext:GridPanel ID="gvErrors" IDMode="Static" runat="server" StoreID="storeErrors"
                                            HideHeaders="true" Frame="True" StripeRows="True" AutoScroll="true" SelectionSavingBuffer="10"
                                            AutoExpandColumn="Message" DisableSelection="true" Title="<%$ Resources:CustomerValidation %>">
                                            <ColumnModel>
                                                <Columns>
                                                    <ext:RowNumbererColumn />
                                                    <ext:Column DataIndex="IsError" Sortable="True">
                                                        <Renderer Fn="renderType" />
                                                    </ext:Column>
                                                    <ext:Column ColumnID="Message" DataIndex="Message" Sortable="True" />
                                                </Columns>
                                            </ColumnModel>
                                            <Buttons>
                                                <quadz:CoolitePermitButton runat="server" IDMode="Static" ID="btnAddLoan" Text="<%$ Resources:AddLoanButton %>"
                                                    PermissionName="AddLoan" HideAsDisabled="true" Icon="Accept">
                                                    <AjaxEvents>
                                                        <Click OnEvent="btnAddLoan_Clicked" />
                                                    </AjaxEvents>
                                                </quadz:CoolitePermitButton>
                                            </Buttons>
                                        </ext:GridPanel>
                                    </ext:LayoutRow>
                                </ext:RowLayout>
                            </Body>
                            <BottomBar>
                                <ext:StatusBar ID="statusBar" runat="server">
                                    <Items>
                                        <ext:Button runat="server" IDMode="Static" ID="btnBack" Text="<%$ Resources:BackButton %>"
                                            Icon="ArrowUndo">
                                            <AjaxEvents>
                                                <Click OnEvent="btnBack_Clicked" />
                                            </AjaxEvents>
                                        </ext:Button>
                                    </Items>
                                </ext:StatusBar>
                            </BottomBar>
                        </ext:Panel>
                    </ext:LayoutRow>
                </ext:RowLayout>
            </Body>
        </ext:Panel>
    </ext:FitLayout>
</asp:Content>
